import java.util.*;
//统计差在l和r范围的数对
public class code2 {
    //排序+前缀和+滑动窗口：差值在【0，r】-差值在【0，l-1】
    public static int n;
    public static int l, r;
    public static int[] a;
    //找差值在[0,x]有多少个
    public static long find(int x) {
        long ret = 0;
        int left=0,right=0;
        while(right<n) {
            while(a[right]-a[left]>x) {
                left++;
            }
            ret += right-left;
            right++;
        }
        return ret;
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();l=sc.nextInt();r=sc.nextInt();
        a = new int[n];
        for(int i=0;i<n;i++) a[i]=sc.nextInt();
        Arrays.sort(a);
        System.out.println(find(r)-find(l-1));
    }
}
